package com.example.myapplication.finger_guest;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.example.day01.R;

public class GuestActivity01 extends AppCompatActivity implements View.OnClickListener {
    RadioGroup guessRg;
    Button submitBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guest01);
        guessRg=findViewById(R.id.guess_rg);
        submitBtn=findViewById(R.id.guess_btn);
        submitBtn.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.guess_btn:
                int buttonId = guessRg.getCheckedRadioButtonId();
                RadioButton checkedRb=findViewById(buttonId);
                //获取被选中的文字
                String message = checkedRb.getText().toString();
                //跳转到下一个页面，斌携带信息
                Intent intent = new Intent();
                intent.setClass(this,GuestActivity02.class);
                intent.putExtra("jia",message);
                startActivity(intent);
                //销毁当前
                finish();
                break;
        }
    }
}
